<template>
	<m-layout title="冻结明细">
		<template v-for="(item,index) in listArr">
			<m-block gap="22 24" spa="0 0 20 0 ">
				<view class="flex-between">
					<view class="flex">
						<m-text color="#222222">{{TradeType[item.tradetype]}}：</m-text>
						<m-text color="#222222" spa="0 0 0 15" size="30" weight="600">{{item.lockbalance}}</m-text>
					</view>
					<template v-if="item.processed == 0">
						<m-text color="# ">冻结中</m-text>
					</template>
					<template v-if="item.processed == 1">
						<m-text color="#999">已解冻</m-text>
					</template>
				</view>
				<view class="">
					<m-text display="block" color="#999999" spa="20 0 0 0">{{item.createtime | mkfsTime}}</m-text>
				</view>
			</m-block>
		</template>
		<m-loading :pageIndex="pageIndex" :pageCount="pageCount" :loading="isLoading" />
	</m-layout>
</template>

<script>
	import { mapState } from 'vuex';
	import { GetLockRecord } from '@/api/Trade.js'
	export default {
		data() {
			return {
				coinid: 0,
				listArr: [],
				pageIndex: 1,
				pageCount: 1,
				isLoading: true,
			};
		},
		computed: {
			...mapState({
				enum: state => state.general.enum
			}),
			TradeType() {
				return this.enum['TradeType']
			}
		},
		watch: {},
		onLoad({ coinid }) {
			this.coinid = coinid;
			this.reset()
		},
		methods: {

			reset() {
				this.pageCount = 1;
				this.pageIndex = 1;
				this.getData();
			},
			async getData() {
				if (this.pageIndex > this.pageCount) {
					return
				}
				this.isLoading = true;
				const { list, pageCount } = await GetLockRecord({
					coinid: this.coinid,
					PageIndex: this.pageIndex,
				});
				this.isLoading = false;
				this.pageCount = pageCount;
				if (this.pageIndex <= 1) {

					this.listArr = list;
				} else {
					this.listArr = [...this.listArr, ...list];
				}
				this.pageIndex++;
				uni.stopPullDownRefresh();
			},
		},
		onPullDownRefresh() {
			this.reset();
		},
		onReachBottom() {
			this.getData();
			console.log("触底了");
		},
	}
</script>

<style lang="scss">

</style>